import { EVENT_NAME_ENUM } from "../../base/EnumIndex";
import { EventManager } from "../../manager/EventManager";


const { ccclass, property } = cc._decorator;

@ccclass
export default class Level_18_77 extends cc.Component {

    @property(cc.Node)
    zj: cc.Node = null;
    speed: number = 0.1;

    JS: number = 0;


    onLoad() {

        EventManager.ins.on(EVENT_NAME_ENUM.FINISH_INTER_TWEEN, this.finish, this);

    }
    onDestroy() {
        EventManager.ins.off(EVENT_NAME_ENUM.FINISH_INTER_TWEEN, this.finish, this);

    }

    finish(finishStr: any) {
        if (typeof finishStr != "string") {
            return;
        }
        if (finishStr.includes("speed77_")) {
            let addSpeed = Number(finishStr.split("speed77_")[1]);
            this.speed += addSpeed / 10;
            cc.log("speed", this.speed);
            this.cheAni1(this.speed);
        }
        if (finishStr.includes("JS77_")) {
            let addJS = Number(finishStr.split("JS77_")[1]);
            this.JS += addJS;
            cc.log(this.JS);
            if (this.JS == 4) {
                // 打开汉堡 碰撞节点、
                this.zj.getChildByName("node11").active = true;
                this.zj.getChildByName("node22").active = false;
            }
        }
    }


    cheAni1(speed2: number) {

        let animation = this.node.getComponent(cc.Animation).getAnimationState("背景动画18_77");
        //    let speed1 = animation.play("背景动画18_77");
        // animation.play("")
        animation.speed = speed2
    }



    // update (dt) {}
}
